{extend name="$_tpl_public_layout_ace"/}


{block name="breadcrumb"}
<ul class="breadcrumb">
	<li><i class="fa fa-home home-icon"></i><a href="{:url('manage/index/index')}">{:config('web_site_title')}</a></li>
	<li><a href="{:url('seatsel/manage/index')}">{:config('proj_name')}</a></li>
	<li><a href="{:url('seatsel_manage/product/index')}">{$sideName}</a></li>
</ul>
{/block}


{block name="pageheader"}
<h1>
	{$sideName}
</h1>
{/block}


{block name="content"}
<style type="text/css">
.fix-input-group{display: inline-table;}

/*运费*/
.delivery-box .control-label{padding-top: 3px;margin-right: 5px;}
</style>

<link rel="stylesheet" href="__STATIC__/Zz22zzUI/localResizeIMG4/h5upload_batch.css" />

<div class="box0 box-primary0">
	<div class="box-body0">

<form method="post" action="{:url('seatsel_manage/product/doAdd')}" enctype="multipart/form-data" class="form-horizontal J_ajaxForm">
	<input type="hidden" name="id" value="{$id}" />

	<h3 class="form-lighter">基本信息</h3>

	<div class="form-group">
		<label class="col-sm-2 control-label">商品模式</label>
		<div class="col-sm-5">
			<?php echo optionRadioHtmlB($product_mode_config, 'data[good_mode]', $info['good_mode']); ?>
		</div>
		<div class="col-sm-5">相同商品模式支持购物车购买</div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">商品名称</label>
		<div class="col-sm-5"><input type="text" name="data[name]" value="{$info['name']}" class="form-control" /></div>
		<div class="col-sm-5"></div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">演出地点</label>
		<div class="col-sm-5"><input type="text" name="data[place]" value="{$info['place']}" class="form-control" /></div>
		<div class="col-sm-5"></div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">类别</label>
		<div class="col-sm-5">
			<?php echo optionRadioHtmlB($categoryList, 'data[cid]', $info['cid'], 'name', 'id'); ?>
		</div>
		<div class="col-sm-5"></div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">封面图片</label>
		<div class="col-sm-5">
			<div class="simpleupload-wrap">
				<div class="upload-box upload--picture-card" data-imgfile="{$info['picurl']}">
					<div class="upload-dragger"></div>
					<input class="simpleupload-file" type="file" id="picurl" name="picurl" accept="image/jpg, image/png, image/jpeg">
					<input class="simpleupload-delfile" type="hidden" name="picurl_del">
				</div>
				<div class="upload-tip">大小2M以下,建议尺寸640×288px</div>
			</div>
		</div>
		<div class="col-sm-5"></div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">商品图片</label>
		<div class="col-sm-10">
			<div class="photoList J_h5upload_patch">
				<ul>
					{volist name="pictureList" id="vo"}
						<li data-id="{$key}"><input type="hidden" name="flashatt[{$key}]" value="{$key}"><div class="lr lr-ui success"><div class="lr-hint"><div class="lr-ready"><i class="fa fa-camera"></i><span>点击上传</span></div><div class="lr-waiting"><i class="fa fa-spinner"></i></div></div><div class="lr-success"><div class="lr-remove"><i class="fa fa-trash"></i></div><img class="lr-img" src="{$vo['picurl']}"></div><input type="file"></div><a class="set_cover">调整顺序</a></li>
					{/volist}
				</ul>
				<div class="lr lr-ui ready"><div class="lr-hint"><div class="lr-ready"><i class="fa fa-camera"></i><span>点击上传</span></div><div class="lr-waiting"><i class="fa fa-spinner"></i></div></div><div class="lr-success"><div class="lr-remove"><i class="fa fa-trash"></i></div><img class="lr-img"></div><input type="file"></div>
			</div>
			使用手机拍照建议横着拍，标准尺寸：480*320
			<div id="upload-container"></div>
		</div>
	</div>

	<h3 class="form-lighter">物流信息</h3>

	<div class="form-group">
		<label class="col-sm-2 control-label">配送方式</label>
		<div class="col-sm-5">
			<label class="checkbox-inline"><input type="checkbox" name="allow_delivery_method[]" value="1" {$info['is_selfpickup'] == 1 ? 'checked' : ''} />自提</label>
			<label class="checkbox-inline"><input type="checkbox" name="allow_delivery_method[]" value="2" {$info['is_express'] == 1 ? 'checked' : ''} />快递</label>
			<label class="checkbox-inline"><input type="checkbox" name="allow_delivery_method[]" value="4" {$info['is_fictitious'] == 1 ? 'checked' : ''} />电子卡券（无需配送）</label>
		</div>
		<div class="col-sm-5"></div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">运费</label>
		<div class="col-sm-9 delivery-box">
			<div class="form-inline mb10">
				<label class="control-label"><input type="radio" name="dataExtend[delivery]" value="0" <?php echo $info['delivery'] == 0 ? 'checked' : '';?>> 统一运费
				</label>
				<div class="input-group fix-input-group zz-length3">
					<div class="input-group-addon">￥</div>
					<input type="text" class="form-control" name="dataExtend[postage]" value="{$info['postage']}" placeholder="0.00">
				</div>
			</div>
			<div class="form-inline mb10">
				<label class="control-label"><input type="radio" name="dataExtend[delivery]" value="1" <?php echo $info['delivery'] == 1 ? 'checked' : '';?>> 运费模板
				</label>
				<div class="input-group fix-input-group">
					<select id="J_deliveryTemplate" name="dataExtend[delivery_template]" class="form-control">
						{volist name="deliveryList" id="vo"}
							<?php
								$selected = $vo['id'] == $info['delivery_template'] ? 'selected' : '';
							?>
							<option value="{$vo['id']}" data-type="{$vo['valuation_type']}" {$selected}>{$vo['name']}</option>
						{/volist}
					</select>
				</div>
			</div>
<?php
	if ($info['delivery_template'] == 2) {
		$deliveryWeightShow = '';
	} else {
		$deliveryWeightShow = 'hide';
	}
?>
			<div class="form-inline js-delivery-sku-weight J_delivery_sku_weight {$deliveryWeightShow}" style="display: none;">
				<div class="input-group">
					<p>当前运费模版，按物流重量（含包装）计费</p>
					<div>
						<label class="pull-left">
							<em class="required">*</em>
							物流重量:
						</label>
						<div style="margin-left: 80px;">
							<div class="input-group fix-input-group zz-length3">
								<div class="input-group-addon">Kg</div>
								<input type="text" class="form-control" name="dataExtend[weight]" value="{$info['weight']}" placeholder="0.00">
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<h3 class="form-lighter">活动设置</h3>

	<div class="form-group">
		<label class="col-sm-2 control-label">每人限购</label>
		<div class="col-sm-5">
			<input type="text" name="data[limit_num]" value="{$info['limit_num']}" class="form-control" />
		</div>
		<div class="col-sm-5 help-block">设置为0即为不限制</div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">购买期限</label>
		<div class="col-sm-5"><input type="text" name="data[start_time]" value="{$info['start_time_show']}" class="form-control disinline zz-length3 J_datetimepicker" /> - <input type="text" name="data[end_time]" value="{$info['end_time_show']}" class="form-control disinline zz-length3 J_datetimepicker" /></div>
		<div class="col-sm-5 help-block">限制用户购买商品的时间范围</div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">使用期限</label>
		<div class="col-sm-5"><input type="text" name="data[verify_start_time]" value="{$info['verify_start_time_show']}" class="form-control disinline zz-length3 J_datetimepicker" /> - <input type="text" name="data[verify_end_time]" value="{$info['verify_end_time_show']}" class="form-control disinline zz-length3 J_datetimepicker" /></div>
		<div class="col-sm-5 help-block">限制用户核销商品的时间范围</div>
	</div>

	<h3 class="form-lighter">核销方式</h3>

	<div class="form-group">
		<label class="col-sm-2 control-label">领奖暗号</label>
		<div class="col-sm-5">
			<input type="text" name="data[verify_code]" value="{$info['verify_code']}" class="form-control" />
		</div>
		<div class="col-sm-5"><p class="form-control-static">核销方式之一</p></div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">核销员用户id</label>
		<div class="col-sm-5">
			<textarea name="data[verify_user]" class="form-control" rows="5">{$info['verify_user']}</textarea>
		</div>
		<div class="col-sm-5"><p class="form-control-static">核销方式之二，请输入用户的id，用英文逗号隔开(支持微信用户和app用户)</p></div>
	</div>

	<h3 class="form-lighter">留言信息</h3>
	<div class="form-group">
		<label class="col-sm-2 control-label">字段选择</label>
		<div class="col-sm-10">
			<div class="callout callout-info">
				排序规则：勾选开启的字段，排序数字大的靠前
				<br>是否必填：填1代表是，填0代表否。
				<br>显示描述：请输入姓名
				<br>
				扩展字段可以自己配置参数，比如设置单选类的：
				<br>
				配置参数里面，这写：
				<br>
				1=aaa
				<br>
				2=bbb
			</div>
			<table class="table table-striped table-condensed">
				<tbody>
					<tr>
						<th width="60">状态</th>
						<th width="100">字段</th>
						<th width="50">排序</th>
						<th width="90">显示名称</th>
						<th width="160">显示描述</th>
						<th width="80">类型</th>
						<th width="50">是否必填</th>
						<th>配置参数</th>
					</tr>
					{volist name="leavemess_option_config" id="value"}
					<?php
						$thisKey = $key;
						$checked = $leavemess_fields_arr[$thisKey] ? 'checked' : '';
					?>
					<tr>
						<td><input type="checkbox" name="messageCheckboxs[{$thisKey}]" value="1" {$checked} /></td>
						<td><p class="form-control-static">{$value['name']}</p></td>
						<td><input type="text" name="messageInputs[{$thisKey}][vieworder]" value="{$leavemess_fields_arr[$thisKey]['vieworder']}" class="form-control" /></td>
						<td><input type="text" name="messageInputs[{$thisKey}][name]" value="{$leavemess_fields_arr[$thisKey]['name']}" class="form-control" /></td>
						<td><input type="text" name="messageInputs[{$thisKey}][desc]" value="{$leavemess_fields_arr[$thisKey]['desc']}" class="form-control" /></td>
						{if condition="$value['issys']"}
							<td></td>
						{else /}
							<td>
								<select name="messageInputs[{$thisKey}][type]" class="form-control">
									<?php
										foreach ($leavemess_type_config as $key2 => $value2) {
										$selected = $leavemess_fields_arr[$thisKey]['type'] == $key2 ? 'selected' : '';
									?>
									<option value="{$key2}" {$selected}>{$value2}</option>
									<?php
										}
									?>
								</select>
							</td>
						{/if}
						<td><input type="text" name="messageInputs[{$thisKey}][required]" value="{$leavemess_fields_arr[$thisKey]['required']}" class="form-control"></td>
						<td><textarea name="messageInputs[{$thisKey}][config]" class="form-control">{$leavemess_fields_arr[$thisKey]['config']}</textarea></td>
					</tr>
					{/volist}
				</tbody>
			</table>
		</div>
	</div>

	<h3 class="form-lighter">分享相关</h3>
	<div class="form-group">
		<label class="col-sm-2 control-label">强制转发</label>
		<div class="col-sm-5">
			<?php echo isOpenRadioHtmlB('data[is_force_forward]', $info['is_force_forward']); ?>
		</div>
		<div class="col-sm-5 help-block"><i class="fa fa-info-circle color-info1"></i>支付前，必须先转发至朋友圈，可以有效提高朋友圈带来的粉丝。</i></div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">分享标题</label>
		<div class="col-sm-5">
			<input type="text" name="data[share_title]" value="{$info['share_title']}" class="form-control" />
		</div>
		<div class="col-sm-5 help-block"><i class="fa fa-info-circle color-info1"></i>如果未设置分享标题，则默认使用商品名称</i></div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">分享描述</label>
		<div class="col-sm-5">
			<input type="text" name="data[share_desc]" value="{$info['share_desc']}" class="form-control" />
		</div>
		<div class="col-sm-5"></div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">分享链接</label>
		<div class="col-sm-5">
			<input type="text" name="data[share_link]" value="{$info['share_link']}" class="form-control" />
		</div>
		<div class="col-sm-5"></div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">分享图标</label>
		<div class="col-sm-5">
			<div class="form-control-static">
				<input type="file" name="share_icon" class="J_uploadfile" />
			</div>
			<div class="J_preview">
				<img src="{$info['share_icon']}" class="cover-img" onerror="Javascript:this.src='/tplnew/public/images/blank.png';" />
			</div>
		</div>
		<div class="col-sm-5 help-block"><i class="fa fa-info-circle color-info1"></i>如果未设置分享图标。则默认使用商品图片</div>
	</div>

	<div class="clearfix form-actions">
		<div class="col-sm-offset-2 col-sm-10">
			<button type="submit" class="btn btn-primary btn-sm J_ajaxSubmit">保存修改</button>
		</div>
	</div>
</form>

	</div>
</div>
{/block}


{block name="script"}
{include file="./tplnew/seatsel_manage/product/h5upload.html" /}

<!-- 新版上传图片 -->
<link rel="stylesheet" href="__STATIC__/Zz22zzUI/localSimpleUpload/localSimpleUpload.css" />
<script type="text/javascript" src="__STATIC__/Zz22zzUI/localSimpleUpload/localSimpleUpload.js"></script>

<!--时间选择器-->
{include file="./tplnew/public/script_datetimepicker.html" /}

<script type="text/javascript">
//是否开启规格
$('.J_specOpen').on('change', 'input:radio', function(e){
	if($(this).val() == 1){
		$('#J_spec_wrap').show();
		$('#J_realPrice').attr('disabled', true);
		$('#J_vipPrice').attr('disabled', true);
		$('#J_originPrice').attr('disabled', true);
		$('#J_productStock').attr('disabled', true);
	}else{
		$('#J_spec_wrap').hide();
		$('#J_realPrice').attr('disabled', false);
		$('#J_vipPrice').attr('disabled', false);
		$('#J_originPrice').attr('disabled', false);
		$('#J_productStock').attr('disabled', false);
	}
});

//价格
$(document).on('keyup', '.J_realPrice', function(){
	var tmp = new Array;
	$(document).find('.J_realPrice').each(function(){
		tmp.push($(this).val());
	});
	$('#J_productRealPrice').val(Math.min.apply(null, tmp))
});

//vip价格
$(document).on('keyup', '.J_vipPrice', function(){
	var tmp = new Array;
	$(document).find('.J_vipPrice').each(function(){
		tmp.push($(this).val());
	});
	$('#J_productVipPrice').val(Math.min.apply(null, tmp))
});

//库存
$(document).on('keyup', '.J_stock', function(){
	var tmp = 0;
	$(document).find('.J_stock').each(function(){
		console.log(parseInt($(this).val()));
		tmp += parseInt($(this).val());
	});
	$('#J_productStock').val(tmp)
});

//商品规格增减
var i = 0;
$('.J_specAdd').click(function(e){
	e ? e.stopPropagation() : event.cancelBubble = true;
	var html = '<tr>';
	html += '<td><input type="text" name="dataSpecNew['+i+'][spec_1]" class="form-control"></td>';
	html += '<td><input type="text" name="dataSpecNew['+i+'][spec_2]" class="form-control"></td>';
	html += '<td><input type="text" name="dataSpecNew['+i+'][real_price]" class="form-control J_realPrice"></td>';
	html += '<td><input type="text" name="dataSpecNew['+i+'][vip_price]" class="form-control J_vipPrice"></td>';
	html += '<td><input type="text" name="dataSpecNew['+i+'][stock_num]" class="form-control J_stock"></td>';
	html += '<td><input type="text" name="dataSpecNew['+i+'][sku]" class="form-control"></td>';
	html += '<td><input type="text" name="dataSpecNew['+i+'][origin_price]" class="form-control"></td>';
	html += '<td><input type="text" name="dataSpecNew['+i+'][weight]" class="form-control"></td>';
	html += '<td><input type="text" name="dataSpecNew['+i+'][vieworder]" class="form-control"></td>';
	html += '<td></td>';
	html += '</tr>';
	$('#J_specBox').append(html);
	i++;
});

//商品规格删除
$('a.J_specLayerConfirm').on('click', function(e){
	e.preventDefault();
	var obj = $(this);
	var url = $(this).attr('href');
	var tip = $(this).data('tip');
	var jump = $(this).data('jump');
	var param = {jump : jump};

	var trObj = $(this).parent().parent();

	layer.confirm(tip, {
		btn: ['确定','取消'], //按钮
		shade: false //不显示遮罩
	}, function(){
		$.get(url, param, function(ret){
			if(ret.code == 1){
				Wei.Util.wapTipNew({msg: ret.msg, icon: 1, data: ret.data}, function(){
					trObj.remove();
				});
			}else if(ret.code == 0){
				Wei.Util.wapTipNew({msg: ret.msg, icon: 2, data: ret.data});
			}

			//Wei.Util.readyToJump(ret);

			try {
				var re = afterConfirm(obj);
				if (re != true) {
					return;
				};
			} catch (err) {

			}
		}, 'json');
	}, function(){
	});
});
</script>

<script type="text/javascript">
//运费
$("#J_deliveryTemplate").change(function(){
	if($(this).find("option:selected").data('type') == 2){
		$('.J_delivery_sku_weight').show();
	}else{
		$('.J_delivery_sku_weight').hide();
	}
})
</script>

<script type="text/javascript">
//留言信息
var js_type = '{$jsAddType}';

$('.J_add_message').on('click', function(e){
	var html = '<div class="message-item"><input type="text" name="messagesNew[name][]" value="留言" class="form-control" maxlength="5"><select class="form-control" name="messagesNew[type][]"><option value="text" selected="">文本格式</option><option value="tel">数字格式</option><option value="email">邮件格式</option><option value="date">日期</option><option value="time">时间</option><option value="id_no">身份证号码</option><option value="image">图片</option></select><label><input type="checkbox" name="messagesNew[required][]" value="1" checked="">必填</label><a href="javascript:;" class="message-remove J_message_remove">删除</a></div>';
	$('.J_message_container').append(html);
});

$('.J_message_remove').on('click', function(e){
	$(this).parent().remove();
});
</script>
{/block}